﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AmazonGlacierGUI.Core.Infrastructure
{
    public static class AppUtility
    {
        public static DateTime GetDate()
        {
            return DateTime.Now;
        }
        public static string GetFileName(string path)
        {
            return Path.GetFileName(path);
        }
        public static  string GetDateString(DateTime date,bool includeTime)
        {
            return date.ToString("dd-MMM-yy hh:mm:ss tt");
        }
        public static bool IsValidFileName(string fileName)
        {
            var fChars = fileName.ToCharArray();
            foreach (var fChar in fChars)
            {
                if (Path.GetInvalidFileNameChars().Contains(fChar))
                    return false;
            }
            return true;

        }
        public static string GetExceptionMessage(Exception ex)
        {
            var sb = new StringBuilder();            
            while (ex != null)
            {
                sb.AppendLine(ex.Message);
                ex = ex.InnerException;
            }
            return sb.ToString();
        }

    }
}
